FileType Class
Represents a REALbasic file type. It provides the functionality of the File Type Sets Editor in the IDE.
More information available in parent classes: Object
Notes
Use the FileType class to programmatically create REALbasic file types, name them, and specify their MacType, MacCreator, file extensions, and icon (if needed).
The FileType class has a built-in conversion to String operator. This enables you to use a FileType object anywhere you would normally use a String to indicate the file type. It also has built-in addition operators that let you add two FileTypes, or a FileType and a String, to get a String. The result is the name of the FileType joined with the other one (or the String) with a semicolon. This is the format required by functions like GetOpenFolderItem. These built-in operators make it possible to work with FileType objects as if they were strings. The example illustrates the operators. You can, of course, specify the file type as a string by passing its name.
Using File Type Sets
In the IDE, each file type is shown as one row in the File Types set table. A File Type set has the String property "All" that returns all of the file types in the set. Use All instead of multiple file types when you want to refer to the group of file types. Suppose you create a File Type Set called ImageTypes in which you specify all of the valid image types that your application can open. You can specify the entire list of image types with a line such as:
The other way to do so is with the "+" operator, i.e.,
assuming that the file types JPEG and MacPICT are the members of the ImageTypes set. The additional advantage of using All is that you can modify the members of the ImageTypes set and you won't need to update your code.
Example
The following example dynamically creates two FileTypes, one for JPEG files and one for PNG files. It then displays an Open File dialog box that allows the selection of only those two file types.
jpegType.Name = "image/jpeg"
jpegType.MacType = "JPEG"
jpegType.Extension = "jpg;jpeg"
Dim pngType As New FileType
pngType.Name = "image/png"
pngType.MacType = "PNG "
pngType.Extension = "png"
Dim f As FolderItem
//using the addition and conversion operators...
f = GetOpenFolderItem( jpegType + pngType )
See Also
FolderItem, FolderItemDialog, GetOpenFolderItem, GetSaveFolderItem, OpenDialog, SaveAsDialog classes.